#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:exercise6.py
# author:wmf
# datetime:2021/3/27 14:39
# software: PyCharm
'''
this is function description
'''
# import module your need

# 给定一个字典,保存了5个同学的学号,姓名,年龄;使用pickle模块将数据对象保存到文件中去;

import pickle,pprint

data = [{'num':'01','name':'Tom','age':18},
        {'num':'02','name':'Bob','age':19},
        {'num':'03','name':'Coco','age':18},
        {'num':'04','name':'Lisa','age':20},
        {'num':'05','name':'Jackson','age':19}]

# selfref_list = [1,2,3]
# selfref_list.append(selfref_list)

file = open('data.txt','wb')
pickle.dump(data,file)
# pickle.dump(selfref_list,file,-1)
file.close()

pkl_file = open('data.txt','rb')
data1 = pickle.load(pkl_file)
pprint.pprint(data1)
# data2 = pickle.load(pkl_file)
# pprint.pprint(data2)
pkl_file.close()
